<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>中信证券账户绑定</title>
    <link rel="stylesheet" type="text/css" href="./images/20240304_public.css">
    <script type="text/javascript" src="./images/20240304-rem.js"></script>
</head>

<body class="mhome">
    <div class="loginTop">
        <p class="topTip"><i><img src="./images/20240304-i1.png" alt=""></i>您正在使用中信证券安全认证页面</p>
    </div>
    <div class="wrapper">
        <div class="scrollbox" style="min-height: 100%;padding-bottom: .8rem;">
            <div class="loginTop">
                <img class="img1" src="./images/20240304-s2-2.png" />
            </div>
            <div class="loginForm">
                <p class="tip"></p>
                <ul>
                    <li class="box box1">
                        <i class="i4"></i>
                        <input type="text" id="fundAccount" placeholder="请输入资金账号" />
                        <div class="accountSelect">
                            <dl class="accountSelectBox"></dl>
                            <p class="more-btn" style="display: none;"><span>点击查看更多</span></p>
                        </div>
                    </li>
                    <li class="box"><i class="i5"></i><input type="password" id="password" placeholder="请输入交易密码"
                            class="passWord" /><i class="i6 see_pass"></i>
                    </li>
                </ul>
                <div>
                    <p class="inputBtn inputBtnJsBox" style="display: none;"><span class="inputBtnJs"  onclick="c_hd_ym_andj('sdsr')">不是我的账号，手动输入>></span></p>
                    <p class="inputBtn selectBtnBox" style="display: none;"><span class="selectBtn"  onclick="c_hd_ym_andj('xzdyzh')">从手机号对应资金账号选择>></span></p>
                </div>
                <a href="javascript:void(0)" onclick="bind();" class="loginBtn mt3 actBtn2">绑定</a>
                <div class="questionBox">
                    <a href="https://channel.citicsinfo.com/bind/customer/d93a72a313944c778f8f695f2af907be"
                        onclick="c_hd_ym_andj('mskh')">马上开户</a>
                    <a href="javascript:void(0)" onclick="skip()">暂不绑定</a>
                </div>
            </div>
            <!--问题咨询-->
            <div class="bottom_question"> 如遇问题请<a href="../c_problem/?ymly=zjzhbdym" class="buleTxt"
                onclick="c_hd_ym_andj('djzl')">点击这里</a><br />或拨打中信证券客服专线<a href="tel:95548"
                    class="buleTxt" onclick="c_hd_ym_andj('95548')">95548</a>
            </div>
        </div>
    </div>
    <!-- 普通提示弹窗 -->
    <div class="mask tiptanBox">
        <div class="tipTan">
            <h2 class="tit">提&nbsp;&nbsp;示</h2>
            <div class="inner">
                <div class="word">
                </div>
            </div>
            <!-- <a href="javascript:void(0)" class="s_btn actBtn">知道了</a> -->
        </div>
    </div>
    <style>
        .toastMask {
            background: none;
        }

        .toastBox {
            background: rgba(0, 0, 0, .7);
            color: #fff;
            padding: .1rem .15rem;
            max-width: 2.5rem;
            border-radius: 8px;
            font-size: .13rem;
            line-height: 2em;
            width: auto;
            text-align: justify;
        }
    </style>
    <div class="mask toastMask">
        <div class="tipTan toastBox">
        </div>
    </div>
    <!-- 账号不一致提示 -->
    <div class="mask confirmtanBox">
        <div class="confirm_tan">
            <div class="word">
                <p>资金账号对应的手机号与当前登录手机号不一致。</p>
            </div>
            <div class="btnBox">
                <a href="javascript:void(0)" class="btn actBtn changeFundAccount" onclick="c_hd_tc_andj2('ghzjzh')">更换资金账号</a>
                <a href="javascript:void(0)" class="btn actBtn changeMobile" onclick="c_hd_tc_andj2('ghsjh')">更换手机号登录</a>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="./images/20240304-jquery-2.0.3.min.js"></script>
    <script src="./images/20240304-public.js" type="text/javascript" charset="utf-8"></script>
    <script>
        function noPassByMobile(str) {
            if (null != str && str != undefined) {
                var pat = /(\d{3})\d*(\d{4})/;
                return str.replace(pat, '$1****$2');
            } else {
                return "";
            }
        }
        function noPassByFundAccount(str) {
            if (null != str && str != undefined) {
                var pat = /(\d{3})\d*(\d{3})/;
                return str.replace(pat, '$1****$2');
            } else {
                return "";
            }
        }
        function setCookie(key, val, time) {
            var date = new Date(); //获取当前时间
            if (time == '' || time == undefined || time == null) { //time为空
                var exdate = new Date();
                exdate.setDate(exdate.getDate() + 365);
                document.cookie = key + "=" + val + "; path=/"; //设置cookie
            } else { //设置cookie留存时间
                var expiresDays = time; //将date设置为n天以后的时间
                date.setTime(date.getTime() + expiresDays * 24 * 3600 * 1000); //格式化为cookie识别的时间
                document.cookie = key + "=" + val + ";expires=" + date.toGMTString() + ";path=/";
            }
        }
        //删除cookie的值
        function delCookie(key) {
            setCookie(key, '', -10);
        }

        //获取cookie的值
        function getCookie(key) {
            /*获取cookie参数*/
            var getCookie = document.cookie.replace(/[ ]/g, ""); //获取cookie，并且将获得的cookie格式化，去掉空格字符
            var arrCookie = getCookie.split(";") //将获得的cookie以"分号"为标识 将cookie保存到arrCookie的数组中
            var tips; //声明变量tips
            for (var i = 0; i < arrCookie.length; i++) { //使用for循环查找cookie中的tips变量
                var arr = arrCookie[i].split("="); //将单条cookie用"等号"为标识，将单条cookie保存为arr数组
                if (key == arr[0]) { //匹配变量名称，其中arr[0]是指的cookie名称，如果该条变量为tips则执行判断语句中的赋值操作
                    tips = arr[1]; //将cookie的值赋给变量tips
                    break; //终止for循环遍历
                }
            }
            return tips;
        }
        //获取地址栏的指定参数
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return decodeURI(r[2]);
            return '';
        }
        function fmtDate(obj) {
            var date = new Date(obj);
            var y = 1900 + date.getYear();
            var m = "0" + (date.getMonth() + 1);
            var d = "0" + date.getDate();
            return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
        }
        function number_format(number, decimals, dec_point, thousands_sep) {
            /*
            * 参数说明：
            * number：要格式化的数字
            * decimals：保留几位小数
            * dec_point：小数点符号
            * thousands_sep：千分位符号
            * */
            number = (number + '').replace(/[^0-9+-Ee.]/g, '');
            var n = !isFinite(+number) ? 0 : +number,
                prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
                sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
                dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
                s = '',
                toFixedFix = function (n, prec) {
                    var k = Math.pow(10, prec);
                    return '' + Math.ceil(n * k) / k;
                };

            s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
            var re = /(-?\d+)(\d{3})/;
            while (re.test(s[0])) {
                s[0] = s[0].replace(re, "$1" + sep + "$2");
            }

            if ((s[1] || '').length < prec) {
                s[1] = s[1] || '';
                s[1] += new Array(prec - s[1].length + 1).join('0');
            }
            return s.join(dec);
        }
    </script>
    <script>
        var sysNo = "CSE010";
        var getTokenUrl = "https://kong.citics.com/api/v1/account/weixin/register";
        var getAccountUrl = "https://kong.citics.com/api/v2/account/get";
        var token = getCookie('token');
        var openid = getCookie('openid');
        var returnUrl = GetQueryString("returnUrl");
        var bindUrl = "https://kong.citics.com/api/v2/financial/personalCenter/bind";
        var mobile = '';
        var code = GetQueryString("code");
        var appid = "wx31465463e2e14fe9";
        var accountno = "gh_abc03753a92c";
        var m_cid = ''
        var ymly = GetQueryString("ymly");
        var fundAccount;
        var fundAccountList = [];
        var getListUsingUrl = 'http://121.89.237.136:18081/activity/portal/CsClientInfo/getList'
        var fundAccountInput = false

        $(function () {
            if (openid == '' || openid == undefined) {
                getWxopenid();
            } else {
                getToken()
            }
        });

        function getToken() {
            var aJson = {
                "sysNo": sysNo,
                "openId": openid,
                "weixinId": accountno
            };
            $.post(getTokenUrl, aJson, function (data) {
                if (data.errorCode == "0" || data.errorCode == 0) {
                    token = data.token;
                    getAccount();
                }
            });
        }
        function getWxopenid() {
            if (code == "" || code == undefined || code == null) {
                var thisUrl = window.location.href;
                thisUrl = encodeURIComponent(thisUrl);
                var theWx = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=";
                var url = theWx + thisUrl + "&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
                window.location.href = url;
            } else {
                //获取openid
                $.ajaxSetup({
                    async: false,
                });
                $.get("https://kong.citics.com/api/v1/wxapi/user/getOpenId?sysNo=" + sysNo + "&code=" + code + "&accountno=" + accountno,
                    function (data) {
                        data = eval("(" + data + ")");
                        if (data.errcode == 0) {
                            openid = data.res_info.openid;
                            setCookie("openid", data.res_info.openid, '');
                            getToken();
                        }
                    })
            }
        }

        function bind() {
            var fundAccountCurr
            if (fundAccountInput) {
                fundAccountCurr = $.trim($('#fundAccount').val());
            } else {
                fundAccountCurr = fundAccount
            }
            var password = $('#password').val();
            if (fundAccountCurr == '') {
                alertMessage("请输入资金账号");
                return;
            }
            if (password == '') {
                alertMessage("请输入交易密码");
                return;
            }
            var parameter = {};
            parameter.token = token;
            parameter.fundAccount = fundAccountCurr;
            parameter.password = password;
            parameter.mobile = mobile;
            parameter.sysNo = sysNo

            c_hd_ym_andj('bd')
            $.ajax({
                url: bindUrl,
                dataType: 'json',
                method: 'post',
                data: parameter,
                success: function (data) {
                    if (data.retCode == 0) {
                        if (returnUrl != '' && returnUrl != undefined) {
                            alertMessage('账户绑定成功！');
                            setTimeout(function () { location.href = decodeURIComponent(returnUrl); }, 1000)
                        } else {
                            alertMessage('账户绑定成功！');
                            setTimeout(function () { location.href = '../memCenter/'; }, 1000)

                        }
                    } else if (data.retCode == '41016') {
                        alertMessage("绑定失败");
                    } else if (data.retCode == '42020') {
                        alertMessage("资金账号或密码有误，请重新输入。");
                    } else if (data.retCode == '50010') {
                        alertMessage("交易密码错误，请重新输入。");
                    } else if (data.retCode == '42016') {
                        $('.confirmtanBox').show();
                    } else if (data.retCode == '42061') {
                        alertMessage("请填写主普通资金账号进行绑定。");
                    }
                    else {
                        alertMessage(data.retMessage);
                    }
                }
            });
        }

        $(".see_pass").click(function () {
            if ($(this).hasClass("on")) {
                $(this).removeClass("on");
                $(".passWord").attr("type", 'password')
            } else {
                $(this).addClass("on");
                $(".passWord").attr("type", 'text')
            }
        })
        $(".closeMask").click(function () {
            $(".mask").hide();
        })

        $('.changeFundAccount').click(function () {
            $(".mask").hide();
        });
        $('.changeMobile').click(function () {
            location.href = '../memMessage/';
        });

        $(document).on('click', '.canSelect', function () {
            if(!$(this).hasClass('showList')){
                c_hd_ym_andj('xlzk')
            }
            $(this).toggleClass("showList");
        })
        $(document).on("click", ".accountSelectBox dd", function () {
            c_hd_ym_andj('xzzh')
            var idx = $(this).index();
            $("#fundAccount").val($(this).html());
            if(fundAccountList[idx].fundAccount != fundAccount){
                $("#password").val('')
            }
            fundAccount = fundAccountList[idx].fundAccount;
            clientId = fundAccountList[idx].clientId;
        })

        //是否绑定资金帐户
        function getAccount() {
            $.ajax({
                url: getAccountUrl,
                method: 'POST',
                dataType: 'json',
                data: { 'sysNo': sysNo, 'token': token },
                success: function (data) {
                    mobile = data.mobile;
                    m_cid = data.cid
                    page_view_ll('zjzhbdym', ymly)

                    if (data.mobile != '' && data.mobile != undefined) {
                        // $('#fundAccount').attr('placeholder', '请输入' + noPassByMobile(data.mobile) + '对应的资金账号');
                        getListUsingGET()
                    } else {
                        if (returnUrl == '' || returnUrl == undefined) {
                            location.href = '../login.html';
                        } else {
                            location.href = '../login.html?returnUrl=' + returnUrl;
                        }

                    }
                }

            });
        }

        // 手机号关联资金账号列表
        function getListUsingGET() {
            // $('.login_repeat').show()

            // 测试 - 开始
            // var token = mobile
            var token = '15712954684'
            // 测试 - 结束

            $.ajax({
                url: getListUsingUrl,
                method: 'get',
                dataType: 'json',
                data: { 'token': token },
                success: function (data) {
                    if (data.data != undefined && data.data.length != 0) {
                        // data.fundAccountList = [
                        //     {
                        //         fundAccount: '111',
                        //         clientId: 'c111'
                        //     },
                        //     {
                        //         fundAccount: '222',
                        //         clientId: 'c222'
                        //     },
                        //     {
                        //         fundAccount: '333',
                        //         clientId: 'c333'
                        //     },
                        //     {
                        //         fundAccount: '333',
                        //         clientId: 'c333'
                        //     }
                        // ]

                        fundAccountList = data.data;

                        fundAccount = fundAccountList[0].fundAccount;
                        clientId = fundAccountList[0].clientId;
                        $("#fundAccount").val(getStr(fundAccount));

                        var html = ''
                        fundAccountList.forEach(item => {
                            html += '<dd>' + getStr(item.fundAccount) + '</dd>'
                        })
                        $('.accountSelectBox').html(html)
                        $('#fundAccount').attr('readonly', true)

                        if (fundAccountList.length === 1) {
                            $('.loginForm .tip').html('您好，系统已根据您输入的手机号匹配出资金账号，请输入资金账号密码进行绑定：')
                        } else {
                            $('.box1').addClass('canSelect')
                            $('.loginForm .tip').html('您好，系统检测到当前手机号对应多个资金账号，请选择常用资金账号进行绑定：')
                        }

                        if (fundAccountList.length > 2) {
                            $('.more-btn').show()
                        }

                        if (fundAccountList.length > 1) {
                            $('.box1').addClass('canSelect')
                        }
                        fundAccountInput = false

                        $('.inputBtnJsBox').show()
                    } else {
                        fundAccountInput = true
                        $('#fundAccount').attr('readonly', false)
                        $('.box1').removeClass('canSelect')
                        $('#fundAccount').attr('placeholder', '请输入' + noPassByMobile(data.mobile) + '对应的资金账号');
                        $('.loginForm .tip').hide()
                        $('.inputBtn').hide()
                    }
                }
            })
        }

        // 点击查看更多
        $('.more-btn').click(function (e) {
            c_hd_ym_andj('djckgd')
            e.stopPropagation()
            $('.accountSelect').addClass('showAll')
            $('.more-btn').hide()
        })

        // 手动输入
        $('.inputBtnJs').click(function () {
            $('#fundAccount').attr('readonly', false).val('').focus()
            $('.box1').removeClass('canSelect')
            $('.loginForm .tip').css('display', 'none')
            $('.inputBtnJsBox').hide()
            $('.selectBtnBox').show()
            
            $("#password").val('')
            fundAccountInput = true
        })
         // 从手机号下拉
         $('.selectBtn').click(function () {
            $('#fundAccount').attr('readonly', true).val(getStr(fundAccount))
            if (fundAccountList.length === 1) {
                $('.loginForm .tip').html('您好，系统已根据您输入的手机号匹配出资金账号，请输入资金账号密码进行绑定：')
            } else {
                $('.box1').addClass('canSelect')
                $('.loginForm .tip').html('您好，系统检测到当前手机号对应多个资金账号，请选择常用资金账号进行绑定：')
            }
            $('.loginForm .tip').css('display', 'block')
            $('.inputBtnJsBox').show()
            $('.selectBtnBox').hide()
            $("#password").val('')
            fundAccountInput = false
        })


        $('.s_btn').bind('click', function () {
            $('.tiptanBox').fadeOut();
        });

        function alertMessage(message) {
            $('.toastBox').html(message);
            $('.toastMask').fadeIn();
            setTimeout(function () { $('.toastMask').fadeOut(); }, 1500)
        }

        function skip() {
            c_hd_ym_andj('zbbd')
            if (returnUrl == '' || returnUrl == undefined) {
                location.href = '../memCenter/';
            } else {
                location.href = decodeURIComponent(returnUrl);
            }
        }
        document.body.addEventListener('touchstart', function () { })

        function getStr(str) {
            return str.substring(0, 3) + "****" + str.substring(str.length - 3, str.length);
        }

    </script>
    <script type="text/javascript" src="./images/jweixin-1.0.0.js"></script>
    <script>
        //初始化微信分享参数--开始
        var wxappid = "";
        var timestamp = "";
        var nonceStr = "";
        var signature = "";
        var getWXShareParamUrl = "https://kong.citics.com/api/v1/financial/weixin/getWxConfig";

        initWxShareParams();
        //初始化微信分享参数--结束

        //微信分享--开始
        wx.config({
            debug: false,
            appId: wxappid,
            timestamp: timestamp,
            nonceStr: nonceStr,
            signature: signature,
            jsApiList: [
                'onMenuShareTimeline',
                'onMenuShareAppMessage'
            ]
        });
        wx.ready(function () {
            wx.hideOptionMenu();
        })
        wx.error(function (res) { });

        //微信分享--结束		   
        //初始化微信分享参数
        function initWxShareParams() {
            var requestUrl = window.location.href;
            $.ajaxSetup({
                async: false,
            });
            $.post(getWXShareParamUrl, {
                "accessUrl": requestUrl
            },
                function (data) {
                    if (data.retCode == "0") {
                        var iData = data.resultSet[0];
                        wxappid = iData.appId;
                        timestamp = iData.timestamp;
                        nonceStr = iData.nonceStr;
                        signature = iData.signature;
                    }
                })
        }
    </script>
    <script>
        (function (i, d, t, o, u, h, s, f) {
            i[t] = i[t] || [], i[t].push(h); i[h] = i[h] || function () {
                return (i[h].q = i[h].q || []).push(arguments)
            }; s = d.createElement(o); s.src = u;
            s.async = 1; f = d.getElementsByTagName(o)[0]; f.parentNode.insertBefore(s, f);
        })(window, document, "HyperAnalyticsObject", "script", "//tracker.citicsinfo.com/hwt.js?v=1.6", "_cita");
        _cita("create", "4229", {
            "storage_id": "_hid",
            "api_url": "//tracker.citicsinfo.com",
            "swf_url": "//tracker.citicsinfo.com/storage.swf#",
            "iframe_url": "//tracker.citicsinfo.com/storage.html"
        });
        _cita("send", "pageview");
        function page_view_ll(ymmc, ymly) {
            var option = {
                "wx_yh": m_cid,
                "wx_llyhsb": openid,
                "ymlx": '官微功能页',
                "ymmc": ymmc,
                "ymly": ymly,
            }
            _cita("send", "action", "c_gwh5_ymll", option);
        }
        function page_view_click(ymmc, anmc) {
            var option = {
                "wx_yh": m_cid,
                "wx_llyhsb": openid,
                "ymlx": '官微功能页',
                "ymmc": ymmc,
                "anmc": anmc
            }
            _cita("send", "action", 'c_hd_ym_andj', option);
        }

        function c_gwh5_ymll() {
            var option = {
                "wx_yh": m_cid,
                "wx_llyhsb": openid,
                "ymlx": '官微功能页',
                "ymmc": 'newzjzhbd',
                "ymly": ymly
            }
            _cita("send", "action", 'c_gwh5_ymll', option);
            console.log('c_gwh5_ymll', option)
        }

        c_gwh5_ymll()

        function c_hd_ym_andj(anmc) {
            var option = {
                "wx_yh": m_cid,
                "wx_llyhsb": openid,
                "ymlx": '官微功能页',
                "ymmc": 'newzjzhbd',
                "anmc": anmc
            }
            _cita("send", "action", 'c_hd_ym_andj', option);
            console.log('c_hd_ym_andj', option)
        }


        function c_hd_tc_andj2(anmc) {
            var option = {
                "wx_yh": m_cid,
                "wx_llyhsb": openid,
                "ymlx": '官微功能页',
                "tcnr": 'sjhbyz',
                "anmc": anmc
            }
            _cita("send", "action", 'c_hd_tc_andj', option);
            console.log('c_hd_tc_andj',anmc)
        }



    </script>
    <div style="display:none">
        <script type="text/javascript" src="https://s9.cnzz.com/z_stat.php?id=1278735516&web_id=1278735516"></script>
    </div>
</body>

</html>